﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using log4net.Core;
//using log4net.Repository.Hierarchy;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace NETCORE.Log4Net1.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {

        public ILoggerFactory _loggerFactory = null;
        public ILogger<TestController> _logger = null;



        public TestController(ILoggerFactory loggerFactory, ILogger<TestController> logger)
        {
            this._loggerFactory = loggerFactory;
            this._logger = logger;
        }


        [Route("get1")]
        [HttpGet]
        public IActionResult Get1()
        {
            this._loggerFactory.CreateLogger<TestController>().LogError("loggerFactory - 这里出了一个错误！");

            this._logger.LogError("logger - 这里出出现了一个错误！");

            return Ok("日志测试！");
        }
    }
}
